package com.imot.handler;

import com.imot.constant.code.ResponseCode;
import com.imot.exception.NotLowestLevelTaskException;
import com.imot.response.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.client.HttpServerErrorException;

import java.net.BindException;
import java.sql.SQLSyntaxErrorException;

import static com.imot.constant.code.ResponseCode.SYSTEM_BUSY;



@RestControllerAdvice
@Slf4j
public class MyExceptionHandler {

    @ExceptionHandler(ImotExciption.class)
    public Result bindException(ImotExciption e){
        log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!123");
        log.info(e.getCode()+"");
        log.info(e.getMsg());
        Result fail = Result.fail(e.getCode(), e.getMsg());
        return fail;
    }

    //    /**
//     * sql异常
//     **/
//    @ExceptionHandler(SQLSyntaxErrorException.class)
//    public Result sqlSyntaxErrorException(SQLSyntaxErrorException e) {
//        return Result.fail(500, "sql错误：" + e.getMessage());
//    }
//
//    /**
//     * HttpServerErrorException
//     **/
//    @ExceptionHandler(HttpServerErrorException.class)
//    public Result httpServerErrorException(HttpServerErrorException e) {
//        return Result.fail(53, "参数校验异常" + e.getMessage());
//    }
//
//    /**
//     * 参数校验异常
//     *
//     * @param e 异常信息
//     * @return com.station.framework.code.domain.Result
//     **/
//    @ExceptionHandler(BindException.class)
//    public Result bindException(BindException e) {
//        return Result.fail(500, "参数校验异常" + e.getMessage());
//    }
//
//    /**
//     * 所有异常拦截
//     * 11:29 2021/7/9
//     *
//     * @param e 异常信息
//     * @return com.station.framework.code.domain.Result
//     **/
//    @ExceptionHandler(Exception.class)
//    public Result bindException(Exception e) {
//        return Result.fail(500, "参数校验异常" + e.getMessage());
//    }

    //当发生 生成的不是 最底层的项目

}
